﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ImobitechModel.com.Controller;

namespace Imobitech.Gestao
{
    public partial class Candidato : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ControladorGestao cg = new ControladorGestao();
            gdvCandidato.DataSource = cg.retornaCandidatos();
            gdvCandidato.DataBind();
        }

        protected void gdvCandidato_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ControladorGestao cg = new ControladorGestao();
            if (e.CommandName.CompareTo("Aceitar") == 0)
            {
                int currentRowIndex = Int32.Parse(e.CommandArgument.ToString());
                cg.aceitarCandidato(int.Parse(gdvCandidato.DataKeys[currentRowIndex].Value.ToString()));
            }
            else if (e.CommandName.CompareTo("Rejeitar") == 0)
            {
                int currentRowIndex = Int32.Parse(e.CommandArgument.ToString());
                cg.retirarCandidato(int.Parse(gdvCandidato.DataKeys[currentRowIndex].Value.ToString()));
            }
        }
    }
}